import 'package:flutter/material.dart';
import 'package:flutter_svg/svg.dart';
import 'package:interview/components/app/app_spread_icon.dart';
import 'package:interview/components/tag.dart';
import 'package:interview/config/app.enum.dart';
import 'package:interview/theme/app_colors.dart';

class QuestionFooter extends StatelessWidget {
  final int likeFlag;
  final List<String> stages;
  final int likeCount;
  final int views;
  final AppColors theme;
  final void Function(String type) onTap;

  const QuestionFooter({
    required this.stages,
    required this.likeCount,
    required this.views,
    required this.theme,
    required this.likeFlag,
    required this.onTap,
    Key? key,
  }) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Container(
      width: double.infinity,
      padding: const EdgeInsets.only(top: 12, left: 16, right: 16, bottom: 24),
      decoration: BoxDecoration(color: theme.contrastMix2, borderRadius: BorderRadius.circular(16)),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.spaceBetween,
        children: [
          Row( children: stages.map((stage) => Padding(padding: const EdgeInsets.all(2), child: Tag(text: stage))).toList()),
          Row(
            mainAxisSize: MainAxisSize.min,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              AppSpreadIcon(
                path:likeFlag == 0 ? "${AppEnumAssets.basePath}like.svg" : "${AppEnumAssets.basePath}like_fill.svg" , 
                flag: likeFlag, 
                onTap: () =>onTap("like"), 
                flagColor: Colors.red, 
                noFlagColor: const Color.fromARGB(255, 221, 221, 221),
                size: 18,
              ),
              SizedBox( width: 8),
              Text(likeCount.toString(),style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color:  theme.contrastMix3!)),
              SizedBox( width: 16),
              SvgPicture.asset(
                "${AppEnumAssets.basePath}read.svg",
                width: 18,
                height: 18,
              ),
              SizedBox( width: 8),
              Text(views.toString(),style: TextStyle(fontSize: 12, fontWeight: FontWeight.w500, color:  theme.contrastMix3!)),
              SizedBox( width: 8),
            ],
          ),
        ],
      ),
    );
  }

}
